package shuai5.action;

import java.util.regex.Pattern;

public class LoginAction extends BaseAction {
	private String username;
	private String password;
	private String zipcode;
	
	public void validateLogin(){
		if(username!=null && username.trim().length()==0){
			addFieldError("username",getText("error.username.required"));			
		}
		if(password!=null && password.trim().length()==0){
			addFieldError("password", getText("error.password.required"));
		}
		
		
		/*System.out.println("执行了validate方法");
		if("".equals(username)){
			addFieldError("username","用户名不能为空");
		}else if (!Pattern.matches("\\w{5,8}", username.trim())) {
			addFieldError("username", "用户名长度必须在5到8之间");
		}*/
	}
	
	public String execute(){
		System.out.println("执行了execute方法");
		return SUCCESS;
	}
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	public String getZipcode() {
		return zipcode;
	}

	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}
	
}
